package com.nenude.corejava.homework3;

import java.util.Scanner;

public class Triangle {

	public static void main(String[] args) {
		
		//使用*号表示，分别打印出三角形，正三角形，反三角形，菱形，空心菱形
		//循环嵌套，循环判断 break、条件分支
		
		      //正三角型
				Scanner scanner=new Scanner(System.in);	
				System.out.println("输入一个行数：");
				int i=scanner.nextInt();	
				
				
				for(int row=1;row<=i;row++){ //行数
					
					for(int k=1;k<=i-row;k++){  //空格数=总行数-所在的行数
						System.out.print(" ");	
					}
					
					for(int col=1;col<=2*row-1;col++)//每一行的星星数
					{								
						System.out.print("*");	
					}
					System.out.println();
				    }
				
				
				
				//反三角形
				/*
				 Scanner scanner=new Scanner(System.in);	
				System.out.println("输入一个行数：");
				int i=scanner.nextInt();
				  for(int row=i;row>=1;row--){ //行数
				
				for(int k=1;k<=i-row;k++){  //空格
					System.out.print(" ");	
				}
				
				for(int col=2*row-1;col>=1;col--)//列数
				{								
					System.out.print("*");	
				}
				System.out.println();
			    }*/
				
				
			//实心菱形：下边比上边少一行				
		/*Scanner scanner=new Scanner(System.in);	
		System.out.println("输入一个行数：");
	  int i=scanner.nextInt();	
		int row1 = 1;
		for (row1 = 1; row1 <= i; row1++) {
			for (int k = 1; k <= i - row1; k++) {
				System.out.print(" ");
			}
			for (int col = 1; col <= 2 * row1 - 1; col++) {
				System.out.print("*");
			}
			System.out.println();
		}

		for (row1 = i - 1; row1 >= 1; row1--) {
			for (int k = 1; k <= i - row1; k++) {
				System.out.print(" ");
			}

			for (int col2 = 2 * row1 - 1; col2 >= 1; col2--) {
				System.out.print("*");
			}
			System.out.println();
		}
				*/
				
			
				
			//空心菱形
		     /* Scanner scanner=new Scanner(System.in);	
		      System.out.println("输入一个行数：");
		      int i=scanner.nextInt();
		      
				int row1 = 1;
				for (; row1 <= i; row1++) {
					for (int k = 1; k <= i - row1; k++) {
						System.out.print(" ");
					}
					for (int col = 1; col <= 2 * row1-1; col++) {
						
						if(col==1 || col==(2*row1-1)){	//判断空心
						System.out.print("*");
						}else {
							System.out.print(" ");
						}				
					}
					System.out.println();
				}
                //下边的反三角
				for (row1 = i - 1; row1 >= 1; row1--) {
					for (int k = 1; k <= i - row1; k++) {
						System.out.print(" ");
					}
					for (int col2 = 2 * row1 - 1; col2 >= 1; col2--) {
						if(col2==1||col2==2*row1-1){
						System.out.print("*");
						
						}else {
							System.out.print(" ");
						}					
					}
					System.out.println();
				}
				*/
				
				
				
				
				
				
				
				
	}

}
